package io.renren.modules.diycake.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.diycake.entity.ShopperEntity;
import io.renren.modules.diycake.service.ShopperService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author mohan
 * @email 1358665425@qq.com
 * @date 2022-01-14 16:34:05
 */
@RestController
@RequestMapping("diycake/shopper")
public class ShopperController {
    @Autowired
    private ShopperService shopperService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("diycake:shopper:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = shopperService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("diycake:shopper:info")
    public R info(@PathVariable("id") Long id){
		ShopperEntity shopper = shopperService.getById(id);

        return R.ok().put("shopper", shopper);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("diycake:shopper:save")
    public R save(@RequestBody ShopperEntity shopper){
		shopperService.save(shopper);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("diycake:shopper:update")
    public R update(@RequestBody ShopperEntity shopper){
		shopperService.updateById(shopper);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("diycake:shopper:delete")
    public R delete(@RequestBody Long[] ids){
		shopperService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    @GetMapping("/getAll")
    public R getAll() {
        return R.ok().put("list",shopperService.list(null));
    }

}
